﻿@model SummaryModel
@using Logistics.Web.Models.Order

@{
    //+string+
    Layout = null;
}

<h3>Summary</h3>
@if (Model.TotalPackages > 0)
{
    <table class="table">
        <tbody>
            @if (Model.CurrentPackages.Count > 0)
            {
                <tr class="summary-total-package">
                    @if (Model.CurrentPackages.Count > 1)
                    {
                        <td class="package-label">Packages</td>
                    }
                    else
                    {
                        <td class="package-label">Package</td>
                    }
                    <td class="package-total">@Model.TotalPackages</td>
                </tr>
            }
            @if (Model.CurrentPackageTotal >= 0 && Model.ShowCurrentPackage)
            {
                <tr>
                    <td>Current Package</td>
                    <td>$@Html.DisplayFor(model => model.CurrentPackageTotal)</td>
                </tr>
                if (Model.TotalPackages > 1)
                {
                    <tr>
                        <td>Other Package(s)</td>
                        <td>$@Html.DisplayFor(model => model.SubTotalExcCurrentPackage)</td>
                    </tr>
                }
            }
            <tr class="summary-subtotal">
                <td class="subtotal-label">Subtotal</td>
                <td class="subtotal-total">$@Html.DisplayFor(model => model.SubTotalExcSurchargeTax)</td>
            </tr>
            @if (Model.Discount != 0)
            {
                <tr class="summary-discount">
                    <td class="tax-label">Discount</td>
                    <td class="tax-price">- $@Html.DisplayFor(model => model.Discount)</td>
                </tr>
            }
            @if (Model.FuelSurcharge > 0)
            {
                <tr class="summary-fuel-surcharge">
                    <td class="fuel-surcharge-label">Surcharge (@Math.Round((Model.FuelSurchargeRate * 100))%)</td>
                    <td class="fuel-surcharge-price">$@Html.DisplayFor(model => model.FuelSurcharge)</td>
                </tr>
            }
            @if (Model.Tax > 0)
            {
                <tr class="summary-tax">
                    <td class="tax-label">Tax (@Math.Round((Model.TaxRate * 100))%)</td>
                    <td class="tax-price">$@Html.DisplayFor(model => model.Tax)</td>
                </tr>
            }
            <tr class="summary-total">
                <td class="total-label">Total</td>
                <td class="total-price">$@Html.DisplayFor(model => model.Total)</td>
            </tr>
        </tbody>


    </table>

}
else
{
    <div>There is no package information currently available.</div>
}
<div class="giftcard-wrapper">
    <h3>Gift Card</h3>
    <div class="logistics-giftcard-message"></div>
    <div class="giftcard-container">
        @if (Model.IsGiftCardApplied)
        {
            <p>You have applied a gift card: <strong>@Model.GiftCardCode</strong></p>
            <div class="giftcard-message"></div>
            <input type="button" class="btn btn-normal form-control gift-card-remove gift-card-action" data-url="@Url.Action("RemoveGiftCard", "Order", new { area = "Logistics" })" data-action="giftCard" value="Remove" />
        }
        else
        {
            <p>You may apply your gift card or coupon code here.</p>
            <div class="giftcard-message"></div>
            @Html.TextBoxFor(model => model.GiftCardCode, new { placeholder = "Gift Card #", Class = "form-control gift-card-field" })
            <input type="button" class="btn btn-normal form-control gift-card-apply gift-card-action" data-url="@Url.Action("AddGiftCard", "Order", new { area = "Logistics" })" data-action="giftCard" value="Apply" />
        }
    </div>
    <div class="logistics-giftcard-loading">
        <img class="loading-svg" src="/Content/images/loading.svg" />
        <img class="loading-gif" src="/Content/images/loading.gif" />
    </div>
</div>